import java.io.File;
import java.io.FileNotFoundException;
import java.util.Scanner;

/**
 * Created with IntelliJ IDEA.
 * User: happyiu
 * Date: 2022-01-25
 * Time: 12:19
 * Description:
 */
public class TestDemo {
    public static int func(int x,int y) throws ArithmeticException{
        if(y == 0){
            throw new ArithmeticException("by zero!");
        }
        return x/y;
    }

    public static void main1(String[] args) {
        System.out.println(func(10, 0));
    }
    public static void main2(String[] args) throws FileNotFoundException {
        System.out.println(readFile());
    }
    public static String readFile() throws FileNotFoundException {
        // 尝试打开文件, 并读其中的一行.
        File file = new File("d:/test.txt");
        // 使用文件对象构造 Scanner 对象.
        Scanner sc = new Scanner(file);
        return sc.nextLine();
    }


}
